import 'package:flutter/material.dart';
import 'package:flutter_live/views/home/live_page.dart';
import 'package:flutter_live/views/home/my_drawer.dart';
import 'package:flutter_live/views/home_bottom_app_bar.dart';

class HomePage extends StatefulWidget {
  HomePage();

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _counter = 0;
  int _selectedIndex = 1;
  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }
  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {

    return DefaultTabController(
      length: 3,
      child: Scaffold(
        appBar: AppBar(
          // Here we take the value from the MyHomePage object that was created by
          // the App.build method, and use it to set our appbar title.
          title: TabBar(
            labelColor: Colors.pink,
            unselectedLabelColor: Colors.black12,
            indicatorColor: Colors.pink,
            indicatorSize: TabBarIndicatorSize.label,
            indicatorWeight: 1.0,
            tabs: <Widget>[
              Text("关注", style: TextStyle(fontSize: 17)),
              Text("热门",style: TextStyle(fontSize: 17)),
              Text("直播",style: TextStyle(fontSize: 17))
            ],
          ),
          elevation: 0,
          centerTitle: true,
          leading: Builder(builder: (context) {
            return IconButton(
              icon: Icon(Icons.person), //自定义图标
              onPressed: () {
                // 打开抽屉菜单
                Scaffold.of(context).openDrawer();
              },
            );
          }),
          actions: <Widget>[
            IconButton(
              icon: Icon(Icons.search),
              onPressed: ()=>debugPrint('search btn pressed'),
            ),
          ],
        ),
        drawer: MyDrawer(),
        body: TabBarView(
          children: <Widget>[

             Icon(Icons.change_history, size: 128.0, color: Colors.black12),
//            BasicDemo(),
             Icon(Icons.directions_bike, size: 128.0, color: Colors.black12),
//             Icon(Icons.message, size: 128.0, color: Colors.black12),
            LivePage(),
//            LayoutDemo(),
//            SliverDemo(),
          ],
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _incrementCounter,
          tooltip: 'home',
          child: Icon(Icons.home,color: Colors.white,size: 35,),
          elevation: 0,
          backgroundColor: Colors.pink[300],
        ),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        bottomNavigationBar: HomeBottomAppBar(),
//       This trailing comma makes auto-formatting nicer for build methods.
      ),
    );
  }
}